package com.isoft.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isoft.entity.Tickets;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TicketsDao {
    /**
     * 插入购票数据
     * @param tickets
     * @return
     */
    @Insert("INSERT INTO AIRPORT.TICKET(USERID,USERNAME,FLIGHTNUM,ENDPLACE,BEGINTIME,STATE) " +
            "VALUES(#{userid},#{username},#{flightnum},#{endplace},#{begintime},#{state})")
    public int addTickets(Tickets tickets);
    /*
    * 根据用户userid查询所购票
    * */
    @Select("SELECT * FROM AIRPORT.TICKET WHERE USERID=#{userid}")
    public IPage<Tickets> selectByUserid(Page<?> page, @Param("userid") Integer userid);
    /*
    * 根据id退票
    * */
    @Update("UPDATE AIRPORT.TICKET SET STATE=0 WHERE ID=#{id}")
    public int tuipiao(@Param("id") Integer id);
    /**
     * 查询购票数据
     * @return
     */
    @Select("select * FROM AIRPORT.TICKET")
    public IPage<Tickets> showTickets(Page<?> page);



}

